package com.honey.mybatis.generator;

import org.java.plugin.Plugin;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Field;
import com.honey.compilation.java.InnerClass;
import com.honey.compilation.java.InnerEnum;
import com.honey.compilation.java.Method;
import com.honey.compilation.java.StaticBlock;
import com.honey.core.compiler.CompilationException;
import com.honey.core.compiler.ContentType;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.generator.java.extension.point.GeneratorJavaClass;
import com.honey.mybatis.generator.MybatisFactory.MybatisClass;

/**
 * 生成Condition 类
 * @author Administrator
 *
 */
public class MybatisPageExtension extends AbstractMybatisExtension implements GeneratorJavaClass{
	
	private AbstractProduceJavaCompilation produceJavaCompilation = null;
	
	private AbstractJavaCompilation abstractJavaCompilation = null;
	
	public MybatisPageExtension(Plugin belongPlugin) {
		super(belongPlugin);
	}
	
	@Override
	public AbstractJavaCompilation createNewCompilation( IntrospectSchema introspectSchema, IntrospectSchemaColumn introspectSchemaColumn) {
		produceJavaCompilation = MybatisFactory.getAbstractProduceJavaCompilation(
				MybatisClass.PAGE, 
				mybatisPlugin, 
				introspectSchema, 
				introspectSchemaColumn
		);
		try {
			abstractJavaCompilation = produceJavaCompilation.produceCompilation();
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return abstractJavaCompilation;
	}

	@Override
	public FullyQualifiedJavaType getType() {
		return abstractJavaCompilation.getType();
	}
	@Override
	public Field[] importFields() {
		Field[] answer = null;
		try {
			answer = produceJavaCompilation.produceFields();
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return answer;
	}

	@Override
	public Method[] importMethods() {
		Method[] answer = null;
		try {
			answer = produceJavaCompilation.produceMethods();
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return answer;
	}
	
	@Override
	public FullyQualifiedJavaType[] importImportClass() {
		FullyQualifiedJavaType[] answer = null;
		try {
			answer = produceJavaCompilation.produceImportClass();
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return answer;
	}

	@Override
	public InnerClass[] importInnerClass() {
		return null;
	}

	@Override
	public InnerEnum[] importInnerEnumClass() {
		InnerEnum[]  answer = null;;
		try {
			answer =produceJavaCompilation.produceInnerEnumClass();
		} catch (CompilationException e) {
			
			e.printStackTrace();
		}
		return answer;
	}

	@Override
	public StaticBlock[] importStaticBlocks() {
		return null;
	}
	
	/* (non-Javadoc)
	 * @see com.honey.generator.java.extension.point.GeneratorJavaClass#getContentType()
	 */
	@Override
	public ContentType getContentType() {
		return ContentType.JAVA_MODEL;
	}

	@Override
	public void clean() {
	}

	
}
